<!--
 * @Descripttion: 总后台框架视图
 * @Copyright: 武汉一一零七科技有限公司©版权所有
 * @Contact: QQ:2487937004
 * @Date: 2020-03-09 17:51:33
 * @LastEditors: cbing
 * @LastEditTime: 2020-05-01 22:54:19
 -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>商家管理-{$webconfig.webtitle}</title>
    <meta name="keywords" content="{$webconfig.keywords}">
    <meta name="description" content="{$webconfig.description}">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <link rel="shortcut icon" href="__PUBLIC__/favicon.ico">
    <link href="__PUBLIC__/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/animate.css" rel="stylesheet">
    <link href="__PUBLIC__/admin/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__PUBLIC__/admin/js/layui/css/layui.css" rel="stylesheet">
    <style>
        body{
            touch-action: none;
        }
        body.fixed-sidebar .navbar-static-side, body.canvas-menu .navbar-static-side{
            width: 170px;
        }
        #page-wrapper{
            margin-left: 170px;
        }
        .content-tabs{
            border: none;
        }
        .navbar-fixed-top, .navbar-static-top{
            /* display: none; */
        }
        #content-main {
            /* height: calc(100% - 80px); */
        }
        .navbar-form-custom{
            width: 250px;
        }
        .fa-sign-out{
            font-size: 16px;
            font-weight: bold;
            color: ;
        }
        .roll-right.btn-group{
            right: 0;
        }
        .roll-right.J_tabRight {
            right: 40px;
        }
        .roll-right.btn-group,.roll-right.btn-group button {
            width: 40px;
        }
    </style>
</head>
<body class="fixed-sidebar full-height-layout gray-bg" style="overflow:hidden">
<div id="wrapper">
    <!--左侧导航开始-->
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="nav-close"><i class="fa fa-times-circle"></i>
        </div>
        <div class="sidebar-collapse">
            <ul class="nav" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element">
                        <span><img alt="image" class="img-logo" src="__PUBLIC__/images/logo_white.png" /></span>
                        <a data-toggle="dropdown" class="dropdown-toggle" href="#" style="display: none;">
                                <span class="clear">
                               <span class="block m-t-xs"><strong class="font-bold">{$Think.session.adminname}</strong></span>
                                <span class="text-muted text-xs block">{$Think.session.rolename}
                                    <!-- <b class="caret"></b> -->
                                </span>
                                </span>
                        </a>
                        <!-- <ul class="dropdown-menu animated fadeInRight m-t-xs">
                            <li><a class="J_menuItem" href="/admin/admin/edit/id/{$Think.session.admin_id}/page/1" data-index="1">修改资料</a>
                            </li>
                        </ul> -->
                    </div>
                    <div class="logo-element">商家</div>
                </li>

                <li>
                    <a class="J_menuItem" href="{:url('index/index_v3')}"><i class="fa fa-home"></i><span class="nav-label">主页</span></a>
                </li>

                <li>
                    <a href="#"><i class="fa fa-bank"></i><span class="nav-label">店铺管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('shops/info')}">店铺基本信息</a></li>
                        <li><a class="J_menuItem" href="{:url('manage_cate/lst')}">店铺经营类目</a></li>
                        <li><a class="J_menuItem" href="{:url('shop_content/info')}">商家详情信息</a></li>
                        <li><a class="J_menuItem" href="{:url('rzmessage/info')}">入驻资料信息</a></li>
                        <!-- <li><a class="J_menuItem" href="{:url('shop_pic/lst')}">店铺banner图信息</a></li> -->
                        <!-- <li><a class="J_menuItem" href="{:url('shop_custom/lst')}">店铺自定义推荐位</a></li> -->
                        <li><a class="J_menuItem" href="{:url('shop_shdz/info')}">售后地址设置</a></li>
                        <li><a class="J_menuItem" href="{:url('sertion/lst')}">服务信息</a></li>
                        <li><a class="J_menuItem" href="{:url('shop_admin/editpwd')}">修改账号密码</a></li>
                        <li><a class="J_menuItem" href="{:url('shop_admin/addpaypwd')}">设置提现密码</a></li>
                        <!--                            <li><a class="J_menuItem" href="{:url('shop_admin/editphone')}">更换登录手机号</a></li>-->
                    </ul>
                </li>

                <li>
                    <a href="#"><i class="fa fa-list-alt"></i><span class="nav-label">账户管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('shop_detail/lst')}">账户明细</a></li>
                        <li><a class="J_menuItem" href="{:url('shop_txmx/index')}">账户提现</a></li>
                        <li><a class="J_menuItem" href="{:url('shop_txmx/lst')}">提现明细</a></li>
<!--                        <li><a class="J_menuItem" href="{:url('shop_recharge/add')}">账户充值</a></li>-->
<!--                        <li><a class="J_menuItem" href="{:url('shop_recharge/lst')}">充值明细</a></li>-->
                        <li><a class="J_menuItem" href="{:url('shop_bankcard/info')}">收款账户设置</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-truck"></i><span class="nav-label">配送方式</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('dispatch/lst')}">配送方式列表</a></li>
                        <li><a class="J_menuItem" href="{:url('dispatch/add')}">添加配送方式</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-soccer-ball-o"></i><span class="nav-label">商品管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('shop_cate/lst')}">店铺商品分类</a></li>
                        <li><a class="J_menuItem" href="{:url('goods/lst')}">商品列表</a></li>
                        <li><a class="J_menuItem" href="{:url('goods/add')}">添加商品</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-map-signs"></i><span class="nav-label">订单管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('order/lst')}">订单列表</a></li>
                        <li><a class="J_menuItem" href="{:url('comment/lst',array('filter'=>3))}">商品评价</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-diamond"></i><span class="nav-label">售后管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('th_apply/lst')}">售后订单列表</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-ticket"></i><span class="nav-label">营销中心</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('coupon/lst')}">优惠券</a></li>
                        <li><a class="J_menuItem" href="{:url('seckill/lst')}">秒杀活动</a></li>
                        <li><a class="J_menuItem" href="{:url('assemble/lst')}">拼团活动</a></li>
                        <li><a class="J_menuItem" href="{:url('promotion/lst')}">商品促销活动</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-video-camera"></i><span class="nav-label">直播管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('live_commision_config/lst')}">直播分成配置</a></li>
                        <li><a class="J_menuItem" href="{:url('live_commision_config/liveGiftGive')}">礼物打赏记录</a></li>
                        <li><a class="J_menuItem" href="{:url('member/blacklst')}">拉黑/禁言列表</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-caret-square-o-right"></i><span class="nav-label">短视频管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('video/lst')}">短视频列表</a></li>
                        <li><a class="J_menuItem" href="{:url('video/add')}">上传短视频</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-ticket"></i><span class="nav-label">积分商城</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('IntegralShop/lst')}">积分活动列表</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-flag"></i><span class="nav-label">新品首发</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('new_publish/lst')}">新品列表</a></li>
                        <li><a class="J_menuItem" href="{:url('new_publish/add')}">发布新品</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#"><i class="fa fa-ticket"></i><span class="nav-label">客服管理</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level">
                        <li><a class="J_menuItem" href="{:url('Member/service')}">更换客服账号</a></li>
                    </ul>
                </li>
                <!--                <li>-->
                <!--                    <a href="#"><i class="fa fa-commenting"></i><span class="nav-label">客服设置</span><span class="fa arrow"></span></a>-->
                <!--                    <ul class="nav nav-second-level">-->
                <!--                        <li><a class="J_menuItem" href="{:url('customer/lst')}">客服列表</a></li>-->
                <!--                        <li><a class="J_menuItem" href="{:url('customerrecord/lst')}">聊天列表</a></li>-->
                <!--                    </ul>-->
                <!--                </li>-->

                <!--新版采集-->


            </ul>
        </div>
    </nav>
    <!--左侧导航结束-->
    <!--右侧部分开始-->
    <div id="page-wrapper" class="gray-bg dashbard-1">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <!-- <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a> -->

                    <form role="search" class="navbar-form-custom">
                        <div class="form-group">
                            <p class="form-control" id="top-search" style="line-height:49px;"><i class="fa fa-tv"></i> {$webconfig.webtitle}·商家管理</p>
                        </div>
                    </form>
                </div>
                <ul class="nav navbar-top-links navbar-right">
                    <li class="dropdown">
                        <!--                            <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#" aria-expanded="false">-->
                        <!--                                <i class="fa fa-bell"></i> <span class="label label-primary">8</span>-->
                        <!--                            </a>-->
                        <ul class="dropdown-menu dropdown-alerts">
                            <li>
                                <a class="J_menuItem" href="{:url('order/lst','filter=1')}">
                                    <div>
                                        <i class="fa fa-comment fa-fw"></i> 待发货订单
                                        <span class="pull-right text-muted small">25个</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a class="J_menuItem" href="{:url('order/lst','filter=4')}">
                                    <div>
                                        <i class="fa fa-commenting fa-fw"></i> 待付款订单
                                        <span class="pull-right text-muted small">5个</span>
                                    </div>
                                </a>
                            </li>
                            <li>
                                <a class="J_menuItem" href="{:url('th_apply/lst','filter=1')}">
                                    <div>
                                        <i class="fa fa-commenting fa-fw"></i> 售后申请订单
                                        <span class="pull-right text-muted small">5个</span>
                                    </div>
                                </a>
                            </li>
                            <li class="divider"></li>
                            <li>
                                <div class="text-center link-block">

                                    <a class="J_menuItem" href="{:url('order/lst')}" data-index="89">

                                        <strong>查看所有 </strong>

                                        <i class="fa fa-angle-right"></i>

                                    </a>

                                </div>

                            </li>

                        </ul>

                    </li>
                    <li>
                        <span style="font-size: 20px" id="translate"></span>
                    </li>

                    <li class="dropdown hidden-xs">
                        <a href="{:url('login/loginout')}" class="right-sidebar-toggle" aria-expanded="false">
                            <i class="fa fa-power-off"></i>
                            <i class="fa fa fa-sign-out"></i> 退出
                        </a>
                    </li>
                </ul>
            </nav>
        </div>

        <div class="row J_mainContent" id="content-main">
            <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="{:url('index_v3')}" frameborder="0" data-id="index_v3.html" seamless></iframe>
        </div>

        <div class="footer">
            <div class="text-center">{$webconfig.web_banquan}</div>
        </div>
    </div>
    <!--右侧部分结束-->

</div>

<!-- 全局js -->
<script src="__PUBLIC__/admin/js/jquery.min.js?v=2.1.4"></script>
<script src="__PUBLIC__/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__PUBLIC__/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__PUBLIC__/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__PUBLIC__/admin/js/plugins/layer/layer.min.js"></script>
<!-- 自定义js -->
<script src="__PUBLIC__/admin/js/hplus.js?v=4.1.0"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/contabs.js"></script>
<!-- 第三方插件 -->
<script src="__PUBLIC__/admin/js/plugins/pace/pace.min.js"></script>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/admin/js/heartbeat.js"></script>
<!-- 联系方式弹窗 -->
    <script src="https://uploadfile.wo-shop.net/customer-pop.js"></script>
<script>
    var token = '{$Request.session.shopsh_token}';
    var avatar = '/{$Request.session.shopsh_logo}';
    var nickname = '{$Request.session.shopsh_name}';

    layui.use('layim', function(layim){
        //基础配置
        layim.config({

            //获取主面板列表信息
            init: {
                url: "{:url('Im/getList')}" //接口地址（返回的数据格式见下文）
                ,type: 'get' //默认get，一般可不填
                ,data: {} //额外参数
            }
            //获取群员接口
            ,members: {
                url: "" //接口地址（返回的数据格式见下文）
                ,type: 'get' //默认get，一般可不填
                ,data: {} //额外参数
            },
            uploadFile: {
                url: "{:url('Common/Upload/uploadPic')}"
            }
            ,uploadImage: {
                url: "{:url('Common/Upload/uploadPic')}"
            }
            ,brief: false //是否简约模式（默认false，如果只用到在线客服，且不想显示主面板，可以设置 true）
            ,title: '客服窗口' //主面板最小化后显示的名称
            ,maxLength: 3000 //最长发送的字符长度，默认3000
            ,isfriend: true //是否开启好友（默认true，即开启）
            ,isgroup: false //是否开启群组（默认true，即开启）
            ,right: '20px' //默认0px，用于设定主面板右偏移量。该参数可避免遮盖你页面右下角已经的bar。
            ,chatLog: "{:url('Im/userChatLog')}" //聊天记录地址（如果未填则不显示）
            ,find: "" //查找好友/群的地址（如果未填则不显示）
            ,copyright: true //是否授权，如果通过官网捐赠获得LayIM，此处可填true
        });

        //建立WebSocket通讯
        var socket = new WebSocket('wss://demo.wo-shop.net:8273');

        //连接成功时触发
        socket.onopen = function(){
            heartCheck.reset().start();      //心跳检测重置
            console.log("websocket握手成功!");
        };

        //监听收到的消息
        socket.onmessage = function(res){
            heartCheck.reset().start();      //心跳检测重置
            console.log('onmessage==============')
            var data = eval("("+res.data+")");
            console.log(data)
            switch(data['type']){
                // 服务端ping客户端
                case 'ping':
                    socket.send('{"type":"ping"}');
                    break;
                // 登录 更新用户列表
                case 'init':
                    console.log("init成功" + data.data.client_id);
                    var client_id = data.data.client_id
                    var sendData = {
                        type: "bind_id",
                        id: "{:session('shopsh_token')}",
                        client_id:client_id,
                    }
                    socket.send(JSON.stringify(sendData));
                    break;
                case 'say':
                    console.log('say==========');
                    console.log(data);
                    var msgData = {
                        avatar: data.data.from_headimgurl,
                        id: data.data.fromid,
                        toid: data.data.fromid,
                        name: data.data.from_username,
                        sign: "2222",
                        type: "friend",
                        username: data.data.from_username,
                        content: data.data.message
                    };

                    layim.getMessage(msgData); //res.data即你发送消息传递的数据（阅读：监听发送的消息）
                    break;
                //添加 用户
                case 'addUser':
                    //console.log(data.data);
                    layim.addList(data.data);
                    break;
                //删除 用户
                case 'delUser':
                    layim.removeList({
                        type: 'friend'
                        ,id: data.data.id //好友或者群组ID
                    });
                    break;
                // 添加 分组信息
                case 'addGroup':
                    // console.log(data.data);
                    layim.addList(data.data);
                    break;
                case 'delGroup':
                    layim.removeList({
                        type: 'group'
                        ,id: data.data.id //好友或者群组ID
                    });
                    break;
                // 检测聊天数据
                case 'chatMessage':
                    layim.getMessage(data.data);

                    break;
                // 离线消息推送
                case 'logMessage':
                    setTimeout(function(){layim.getMessage(data.data)}, 1000);
                    break;
                // 用户退出 更新用户列表
                case 'logout':
                    break;
                //聊天还有不在线
                case 'ctUserOutline':
                    console.log('11111');
                    layer.msg('好友不在线', {'time' : 1000});
                    break;

            }
        };

        //layim建立就绪
        layim.on('ready', function(res){

            layim.on('sendMessage', function(res){
                console.log('sendMessage------------');
                console.log(res);
                // 发送消息
                var mine = JSON.stringify(res.mine);
                var to = JSON.stringify(res.to);
                var typeStr = res.mine.content.substr(0,3);
                var messageType = '';
                if(typeStr == 'img'){
                    messageType = 'img';
                }else{
                    messageType = 'text';
                }
                var sendData = {
                    type:"say",
                    data: {
                        userType: 'customer',
                        fromid: "{:session('shopsh_token')}",
                        toid: res.to.toid,
                        message: res.mine.content,
                        message_type: messageType
                    }
                };
                socket.send( JSON.stringify(sendData) );

            });
        });


        layim.on('chatChange', function(data){
            // 监听每次点击的事件
            console.log('change');
        });

        // layim.chat({ //自定义的聊天版面，可以随时调用
        //     avatar: "/uploads/default.jpg",
        //     id: 1,
        //     name: "商家客服",
        //     sign: "111222333",
        //     type: "friend",
        //     username: "商家客服"
        // });

        //心跳检测
        var heartCheck = {
            timeout: 10000,        //9分钟发一次心跳
            timeoutObj: null,
            serverTimeoutObj: null,
            reset: function(){
                clearTimeout(this.timeoutObj);
                clearTimeout(this.serverTimeoutObj);
                return this;
            },
            start: function(){
                var self = this;
                this.timeoutObj = setTimeout(function(){
                    //这里发送一个心跳，后端收到后，返回一个心跳消息，
                    //onmessage拿到返回的心跳就说明连接正常
                    var sendData = {
                        type: "ping",
                        id:token
                    }
                    console.log(sendData);
                    socket.send(JSON.stringify(sendData));
                    self.serverTimeoutObj = setTimeout(function(){
                        socket.close();
                    },self.timeout)
                }, this.timeout)
            }
        };

    });

</script>
<script>
    translate.selectLanguageTag.languages = 'zh-CN,zh-TW,en';  //注意要放到 translate.execute(); 上面
    translate.execute();
</script>

</body>
</html>
